package projectEuler.net;

public class Problem_043 {
	private static int[] primesFactor = {2, 3, 5, 7, 11, 13, 17};
	
	private static boolean isDifferenceDigitNumber(long abc){
		boolean[] digitRegister = new boolean[10];
		for(int i=0; i<10; i++) digitRegister[i]=false;
		while(abc>0){
			if(!digitRegister[(int) (abc%10)])
				digitRegister[(int) (abc%10)]=true;
			else return false;
			abc/=10;
		}
		return true;
	}
	private static boolean isSpecificFearture(long abc){
		if(!isDifferenceDigitNumber(abc)) return false;
		for(int i = 6; i>=0; i--){
			if((abc%1000)%primesFactor[i] == 0){
				abc=abc/10;
			}else return false;
		}
		return true;
	}
	private static long buildPandigital(int N6, int N3){
		long tmp = (long)N6*1000+(long)N3;
		if(!isSpecificFearture(tmp)) return 0;
		System.out.printf("__%d\n", tmp);
		return tmp;
	}
	public static long sumSpecificPandigital(){
		long tmp_sum = 0;
		for(int i = 17; i<=987; i+=17){
			for(int j=1023456; j<9876543; j++)
				tmp_sum+=buildPandigital(j, i);
		}
		return tmp_sum;
	}
}
